package com.example.springsecuritydemo.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author fair_wu
 * @version v1.0
 * @date 2021-03-05 下午 23:03
 */
@RestController
@RequestMapping("test")
public class testController {

    @PreAuthorize("hasAnyAuthority('admin')")
    @RequestMapping(value = "admin", method = RequestMethod.GET)
    public String testAdmin(){
        return "hello admin";
    }

    @PreAuthorize("hasAnyAuthority('student')")
    @RequestMapping(value = "student", method = RequestMethod.GET)
    public String testStudent(){
        return "hello student";
    }

    @PreAuthorize("hasAnyAuthority('teacher')")
    @RequestMapping(value = "teacher", method = RequestMethod.GET)
    public String testTeacher(){
        return "hello teacher";
    }
}
